<template>
  <div class="stat-card" :class="{ 'hover-effect': isHovering }" @mouseenter="isHovering = true" @mouseleave="isHovering = false">
    <div class="icon-container" :class="icon">
      <svg-icon :icon-class="getIconName()" />
    </div>
    <div class="stat-content">
      <h3>{{ title }}</h3>
      <div class="stat-details">
        <div class="value">{{ value }}</div>
        <div class="change" :class="{ 'positive': !change.includes('-'), 'negative': change.includes('-') }">
          {{ change }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const props = defineProps({
  title: {
    type: String,
    required: true
  },
  value: {
    type: String,
    required: true
  },
  change: {
    type: String,
    required: true
  },
  icon: {
    type: String,
    required: true
  }
});

const isHovering = ref(false);

function getIconName() {
  switch(props.icon) {
    case 'applications':
      return 'form';
    case 'visitors':
      return 'peoples';
    case 'clicks':
      return 'chart';
    case 'users':
      return 'user';
    default:
      return 'chart';
  }
}
</script>

<style scoped>
.stat-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 20px;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  transform-origin: center;
}

.hover-effect {
  transform: scale(1.03);
  box-shadow: 0 5px 15px rgba(0,0,0,0.12);
}

.icon-container {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  transition: all 0.3s ease;
}

.hover-effect .icon-container {
  transform: rotate(5deg);
}

.icon-container.applications {
  background: rgba(74, 128, 255, 0.1);
}

.icon-container.visitors {
  background: rgba(66, 184, 131, 0.1);
}

.icon-container.clicks {
  background: rgba(255, 82, 82, 0.1);
}

.icon-container.users {
  background: rgba(251, 140, 0, 0.1);
}

.applications :deep(svg) {
  color: #4a80ff;
  font-size: 26px;
}

.visitors :deep(svg) {
  color: #42b883;
  font-size: 26px;
}

.clicks :deep(svg) {
  color: #ff5252;
  font-size: 26px;
}

.users :deep(svg) {
  color: #fb8c00;
  font-size: 26px;
}

.stat-content {
  flex: 1;
}

h3 {
  font-size: 14px;
  color: #666;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.stat-details {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.value {
  font-size: 24px;
  font-weight: 600;
  color: #333;
}

.change {
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
}

.positive {
  color: #42b883;
  background: rgba(66, 184, 131, 0.1);
}

.negative {
  color: #ff5252;
  background: rgba(255, 82, 82, 0.1);
}
</style> 